//
//  CASelectDistrictView.m
//  LNH
//
//  Created by twentylx on 2018/2/26.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CASelectDistrictView.h"

@implementation CASelectDistrictView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.districtView];
    [self.districtView addSubview:self.districtSelectLabel];
    [self.districtView addSubview:self.moreImageView];
    [self addSubview:self.districtLabel];
    [self addSubview:self.districtCountLabel];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(20);
        make.top.equalTo(self).offset(20);
    }];
    
    [_districtView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(20);
        make.height.mas_equalTo(50);
    }];
    
    [_districtSelectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.districtView).offset(20);
        make.centerY.equalTo(self.districtView);
    }];
    
    [_moreImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.districtView).offset(-20);
        make.centerY.equalTo(self.districtView);
    }];
    
    [_districtLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.centerY.equalTo(self);
    }];
    
    [_districtCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.districtLabel.mas_bottom).offset(20);
    }];
}

#pragma mark get & set
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"请选择要申请的区域";
        _titleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _titleLabel;
}

- (UIView *)districtView {
    if (!_districtView) {
        _districtView = [UIView new];
        _districtView.backgroundColor = RGBCOLOR(233, 85, 19);
    }
    return _districtView;
}

- (UILabel *)districtSelectLabel {
    if (!_districtSelectLabel) {
        _districtSelectLabel = [UILabel new];
        _districtSelectLabel.text = @"地区";
        _districtSelectLabel.textColor = [UIColor whiteColor];
        _districtSelectLabel.font = [UIFont systemFontOfSize:16];
    }
    return _districtSelectLabel;
}

- (UIImageView *)moreImageView {
    if (!_moreImageView) {
        _moreImageView = [UIImageView new];
        _moreImageView.image = LMImageNamed(@"more");
    }
    return _moreImageView;
}

- (UILabel *)districtLabel {
    if (!_districtLabel) {
        _districtLabel = [UILabel new];
        _districtLabel.textColor = RGBCOLOR(233, 85, 19);
        _districtLabel.font = [UIFont systemFontOfSize:20];
        _districtLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _districtLabel;
}

- (UILabel *)districtCountLabel {
    if (!_districtCountLabel) {
        _districtCountLabel = [UILabel new];
        _districtCountLabel.textColor = RGBCOLOR(233, 85, 19);
        _districtCountLabel.font = [UIFont systemFontOfSize:20];
        _districtCountLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _districtCountLabel;
}


@end
